.TH std::basic_ostream::tellp 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_ostream::tellp \- std::basic_ostream::tellp

.SH Synopsis
   pos_type tellp();

   Returns the output position indicator of the current associated streambuf object.

   Behaves as UnformattedOutputFunction (except without actually          \fI(since C++11)\fP
   performing output). After constructing and checking the sentry object,

   If fail()==true, returns pos_type(-1). Otherwise, returns rdbuf()->pubseekoff(0,
   std::ios_base::cur, std::ios_base::out).

.SH Parameters

   \fI(none)\fP

.SH Return value

   current output position indicator on success, pos_type(-1) if a failure occurs.

.SH Example


// Run this code

 #include <iostream>
 #include <sstream>
 int main()
 {
     std::ostringstream s;
     std::cout << s.tellp() << '\\n';
     s << 'h';
     std::cout << s.tellp() << '\\n';
     s << "ello, world ";
     std::cout << s.tellp() << '\\n';
     s << 3.14 << '\\n';
     std::cout << s.tellp() << '\\n' << s.str();
 }

.SH Output:

 0
 1
 13
 18
 hello, world 3.14

.SH See also

   seekp sets the output position indicator
         \fI(public member function)\fP
   tellg returns the input position indicator
         \fI(public member function of std::basic_istream<CharT,Traits>)\fP
   seekg sets the input position indicator
         \fI(public member function of std::basic_istream<CharT,Traits>)\fP
